package com.yt.order.api.client;

import com.yt.common.constant.Result;
import com.yt.order.models.bo.WorkOrderAutoDispatchBO;
import com.yt.order.models.service.IAutoDispatchService;
import com.yt.order.models.vo.DispatchResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自动派单控制器
 *
 * @author chen
 * @Date 2025-09-22
 */
@RestController
@RequestMapping("/api/autoDispatch")
@Api(value = "AutoDispatchController", tags = "自动派单接口")
public class AutoDispatchController {

    @DubboReference
    private IAutoDispatchService autoDispatchService;

    @PostMapping("/execute")
    @ApiOperation(value = "执行自动派单", notes = "按规则自动分配未派单工单给合适员工")
    public Result<DispatchResultVO> execute(@RequestBody WorkOrderAutoDispatchBO bo) {
        DispatchResultVO result = autoDispatchService.executeAutoDispatch(bo);
        return new Result<>(result);
    }
}